-
Notifications
You must be signed in to change notification settings - Fork 301
Relationship deletion #171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relationship deletion #171
Conversation
Allow the deletion of relationships using the `relationships` values of a request, eg: { "data": { "id": 1, "type": "model", "attributes": { "name": "test-model", "number": 1 }, "relationships": { "other-model": {"data": null} } } } See http://jsonapi.org/format/#crud-updating-to-one-relationships
This looks good, thanks! Would you mind adding a test to this file to demonstrate the fix? https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/example/tests/test_views.py#L140-L146 You can use the highlighted test as an example. |
To delete a relationship, the corresponding value is being overriden with None. Eg: { 'data': { 'type': 'posts', 'relationships': { 'blog': { 'data': None } } } }
Added a unit test for relationship deletion using the |
This does not test the added functionality unfortunately... Any idea on what to add to the example code to have a nullable to-one relationship? |
I think the model can be redefined inside the test function. |
After a closer look at the |
Thank you! |
Yes, thank you :) can we close #169? |
Allow the deletion of relationships using the
relationships
values of a request, eg:See JSON API specification
References #169